﻿<!--
Copyright © 2010 François Karman

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

See <license.txt> for the complete license of the software.
-->
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ex="clr-namespace:Faz.Dependencies.Controls;assembly=Faz.Dependencies.Controls"
        xmlns:l="clr-namespace:Faz.Dependencies"
        Title="MainWindow"
        Height="500"
        Width="600">
    <DockPanel>

        <!-- The available commands -->
        <StackPanel DockPanel.Dock="Top"
                    Orientation="Horizontal">

            <!-- The choose directory command -->
            <HeaderedContentControl Header=""
                                    Style="{l:ApplicationResource StyleMenuHeader}">
                <Button Command="{Binding Path=ChooseDirectory}"
                        Content="Choose Directory" />
            </HeaderedContentControl>

            <!-- The available views -->
            <HeaderedContentControl Header="View Mode"
                                    Style="{l:ApplicationResource StyleMenuHeader}">
                <ListBox Style="{l:ApplicationResource StyleButtonList}">
                    <ToggleButton x:Name="simpleList"
                                  Content="Simple List"
                                  IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}, AncestorLevel=1}, Path=IsSelected, Mode=TwoWay}" />
                    <ToggleButton x:Name="dependencyTable"
                                  Content="Dependency Table"
                                  IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}, AncestorLevel=1}, Path=IsSelected, Mode=TwoWay}" />
                    <ToggleButton x:Name="linkList"
                                  Content="Link View"
                                  IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}, AncestorLevel=1}, Path=IsSelected, Mode=TwoWay}" />
                </ListBox>
            </HeaderedContentControl>

            <!-- The available sort options -->
            <HeaderedContentControl Header="Sort Options"
                                    Style="{l:ApplicationResource StyleMenuHeader}">
                <ListBox Style="{l:ApplicationResource StyleButtonList}">
                    <ToggleButton Command="{Binding Sort}"
                                  CommandParameter="Name"
                                  Content="By Name"
                                  IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}, AncestorLevel=1}, Path=IsSelected, Mode=TwoWay}" />
                    <ToggleButton Command="{Binding Sort}"
                                  CommandParameter="Category"
                                  Content="By Category"
                                  IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}, AncestorLevel=1}, Path=IsSelected, Mode=TwoWay}" />
                    <ToggleButton Command="{Binding Sort}"
                                  CommandParameter="Level"
                                  Content="By Level"
                                  IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}, AncestorLevel=1}, Path=IsSelected, Mode=TwoWay}" />
                </ListBox>
            </HeaderedContentControl>

            <!-- The available filtering options -->
            <HeaderedContentControl Header="Filter Options"
                                    Style="{l:ApplicationResource StyleMenuHeader}">
                <ListBox Style="{l:ApplicationResource StyleButtonList}">
                    <ToggleButton Command="{Binding Filter}"
                                  CommandParameter="All"
                                  Content="No filter"
                                  IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}, AncestorLevel=1}, Path=IsSelected, Mode=TwoWay}" />
                    <ToggleButton Command="{Binding Filter}"
                                  CommandParameter="Indirect"
                                  Content="No third link"
                                  IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}, AncestorLevel=1}, Path=IsSelected, Mode=TwoWay}" />
                    <ToggleButton Command="{Binding Filter}"
                                  CommandParameter="Initial"
                                  Content="Only Initials"
                                  IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}, AncestorLevel=1}, Path=IsSelected, Mode=TwoWay}" />
                </ListBox>
            </HeaderedContentControl>

        </StackPanel>

        <!-- The current directory -->
        <TextBlock DockPanel.Dock="Top">
            <TextBlock Text="Current directory:" />
            <TextBlock Text="{Binding Path=Directory}" />
            <TextBlock.Style>
                <Style TargetType="{x:Type TextBlock}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Path=Directory}"
                                     Value="{x:Null}">
                            <Setter Property="Visibility"
                                    Value="Collapsed" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=Directory}"
                                     Value="">
                            <Setter Property="Visibility"
                                    Value="Collapsed" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </TextBlock.Style>
        </TextBlock>

        <!-- The list view used to display the result -->
        <ScrollViewer HorizontalScrollBarVisibility="Auto"
                      VerticalScrollBarVisibility="Auto">
            <ex:ListViewExtended ItemsSource="{Binding Path=PreparedAssemblies.View}">
                <ex:ListViewExtended.Style>
                    <Style TargetType="{x:Type ListView}"
                           BasedOn="{l:ApplicationResource StyleDefaultList}">
                        <Style.Triggers>
                            <!-- Default style -->
                            <MultiDataTrigger>
                                <MultiDataTrigger.Conditions>
                                    <Condition Binding="{Binding ElementName=dependencyTable, Path=IsChecked}"
                                               Value="False" />
                                    <Condition Binding="{Binding ElementName=linkList, Path=IsChecked}"
                                               Value="False" />
                                </MultiDataTrigger.Conditions>
                                <Setter Property="Template"
                                        Value="{l:ApplicationResource TemplateDefaultList}" />
                            </MultiDataTrigger>
                            <DataTrigger Binding="{Binding ElementName=dependencyTable, Path=IsChecked}"
                                         Value="True">
                                <Setter Property="ItemTemplate"
                                        Value="{l:ApplicationResource TemplateDependencyHeader}" />
                                <Setter Property="ItemContainerStyle"
                                        Value="{l:ApplicationResource StyleDependencyHeaderListItem}" />
                                <Setter Property="View">
                                    <Setter.Value>
                                        <ex:DependencyView DependencyPropertyName="Dependencies"
                                                           ResultContainerStyle="{l:ApplicationResource StyleDependencyResultListItem}"
                                                           ResultTemplate="{l:ApplicationResource TemplateDependencyResultBoolean}"
                                                           ReferenceContainerStyle="{l:ApplicationResource StyleDependencyReferenceListItem}"
                                                           ReferenceTemplate="{l:ApplicationResource TemplateDependencyReference}"
                                                           Corner="{l:ApplicationResource DependencyViewCorner}" />
                                    </Setter.Value>
                                </Setter>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding ElementName=linkList, Path=IsChecked}"
                                         Value="True">
                                <Setter Property="ItemContainerStyle"
                                        Value="{l:ApplicationResource StyleLinkListItem}" />
                                <Setter Property="View">
                                    <Setter.Value>
                                        <ex:LinkView LineStartTemplate="{x:Null}"
                                                     LineEndTemplate="{l:ApplicationResource LinkLineEnd}" />
                                    </Setter.Value>
                                </Setter>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </ex:ListViewExtended.Style>
            </ex:ListViewExtended>
        </ScrollViewer>
    </DockPanel>
</Window>
